var qsd = querystring.parse();
function AppCfg() {
 	return {
 		config: {
 			isDebug: false,
 			// apihost:"http://mgapi.dalujinrong.cn", 
 			apihost: "http://192.168.1.181:9090",
 			//		apihost:"http://localhost:3001", 
 			indexpath: "",
 			/* 首页路径 ，如 http://mg.dalujinrong.cn/dljt/H5N10/ 其首页路径为 /dljt/H5N10 */
 			appkey: "",
 			appkeymust: "",
 			/* 强制使用该appkey值*/
 			sourcemust: 3,
			userid:'1',
 			/* 强制使用 该source值*/
 			url: {
 				// 价格设置管理-查询详情
 				"queryOriginaDetail": "/api/origina/queryOriginaDetail",
 				// 客户信息-取消关注
 				"modifyUserIsFollow": "/api/account/modifyUserIsFollow",
 				// 客户信息-详情
 				"getUserById": "/api/account/getUserById",
 				// 客户信息-订单详情
 				"queryOcobUserByUserId": "/api/account/queryOcobUserByUserId",
 				// 收货地址管理-列表查询
 				"queryAddressInfoList": "/api/address/queryAddressInfoList",
 				// 收货地址管理-详情
 				"getAddressById": "/api/address/getAddressById",
 				// 收货地址管理-删除
 				"removeAddressById": "/api/address/removeAddressById",
 				// 收货地址管理-新增或修改
 				"saveOrUpdateAddress": "/api/address/saveOrUpdateAddress",
 				// 系统配置-查询拼团链接是否已满
 				"queryAssembleIsFull": "/api/origina/queryAssembleIsFull",
 				// 订单信息-更新订单状态
 				"modifyOrderStatus": "/api/order/modifyOrderStatus",
 				// 订单信息-查询物流详情
 				"queryOrderById": "/api/order/queryOrderById",
 				// 订单信息-列表查询
 				"queryOrderPage": "/api/order/queryOrderPage",
 				// 订单信息-删除
 				"removeOrderById": "/api/order/removeOrderById",
 				// 订单信息-新增或修改
 				"saveOrUpdateOrder": "/api/order/saveOrUpdateOrder",
 				// 购物车-列表查询
 				"queryShopCartInfoList": "/api/shopCart/queryShopCartInfoList",
 				// 购物车-删除
 				"removeShopCartById": "/api/shopCart/removeShopCartById",
 				// 购物车-新增或修改
 				"saveOrUpdateShopCart": "/api/shopCart/saveOrUpdateShopCart",
 				// 微信认证
 				"wxAuthorize": "/api/auth/wxAuthorize"
 			},
 			page: {
 				/* 登录*/
 				"login": "/login.html",
 				/* 产品列表*/
 				"productList": "/list.html",
 				/* 产品详情*/
 				"productDetail": "/detail.html"
 			}
 		},

 		init: function(initData) {
 			if (initData) {
 				for (var k in initData) {
 					this.config[k] = initData[k];
 				}
 			}
 			return this;
 		},
 		geturl: function(action) {
 			return this.config.apihost + this.config.url[action];
 		},
 		getAppData: function(string) {
 			return querystring.parse()
 			// return {};
 		},
 		getBrowser: function() {
 			// 浏览器平台，浏览器厂商类型
 		},

 		getParameterString: function(url, data, unSign) {
 			// 暂时不处理非签名字段
 			var str = querystring.stringify(data, "sort");
 			return str;
 		},
 		majax: function(url, data, success, error, dataType,headers) {
 			var that = this;
 			jQuery.ajax({
 				type: 'post',
 				url: url,
 				data: data,
				headers:{
					user_id:''
				},
 				crossDomain: true,
 				contentType: "application/x-www-form-urlencoded; charset=utf-8",
 				dataType: dataType || 'json',
 				success: function(ret, a) {
 					if (that.config.isDebug) {
 						prompt("【" + url + "】return【" + JSON.stringify(ret) + "】");
 					}
 					if (success) {
 						success(ret);
 					}
 				},
 				error: function(e) {
 					if (error) {
 						error(e);
 					}
 				}
 			});
 		},
 		majaxAction: function(action, data, success, error, debug) {
 			this.majax(this.geturl(action), data, success, error, debug);
 		},
 		loadScript: function(url) {
 			var script = document.createElement("script");
 			script.type = "text/javascript";
 			script.src = url + "?v=" + new Date().getTime();
 			document.body.appendChild(script);
 		},
 		loadStyles: function(url) {
 			var link = document.createElement("link");
 			link.type = "text/css";
 			link.rel = "stylesheet";
 			link.href = url;
 			document.getElementsByTagName("head")[0].appendChild(link);
 		},
 		openPage: function(page, queryString) {
 			window.location.href = window.location.origin + this.config.indexpath + this.config.page[page] + "?" + queryString;
 		}
 	};
 }
